package com.example.module_service.device

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.lib_base.path.RouterPath
import com.example.lib_common.view.entity.CarStopEntityItem
import com.example.lib_common.view.view.BaseMvvmActivity
import com.example.module_service.R
import com.example.module_service.adapter.CarStopAdapter
import com.example.module_service.databinding.ActivityCarstopBinding
import com.example.module_service.viewmodel.ServerViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = RouterPath.PATH_CAR_STOP_PAGE)
class CarstopActivity : BaseMvvmActivity<ActivityCarstopBinding>() {
    override fun getLayoutId(): Int=R.layout.activity_carstop

    private lateinit var carStopAdapter: CarStopAdapter

    private val mViewModel:ServerViewModel by viewModels()

    private val mCarStopList:MutableList<CarStopEntityItem> = mutableListOf()


    override fun initViews() {

        carStopAdapter=CarStopAdapter(mCarStopList)
        mDataBinding.rv.run {
            layoutManager=LinearLayoutManager(this@CarstopActivity,LinearLayoutManager.VERTICAL,false)
            adapter=carStopAdapter
        }
    }


    override fun loadData() {
        super.loadData()
        mViewModel.GetCarStop()
    }

    override fun observeDataChang() {
        super.observeDataChang()
        mViewModel.getcarStop.observe(this){
            mCarStopList.clear()
            mCarStopList.addAll(it)
            carStopAdapter.notifyDataSetChanged()
        }
    }
    override fun getActivityState(state: Bundle) {

    }

    override fun saveActivityState(outState: Bundle) {

    }

}